/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author:
 */

import request from '@/utils/request'

// 应用详情
export function detailClient(query) {
  return request({
    url: '/mgr/app',
    method: 'get',
    params: query
  })
}

// 添加应用信息
export function addObjApi(obj) {
  return request({
    url: '/mgr/app/add',
    method: 'post',
    data: obj
  })
}

// 应用开发配置信息
export function configDetailApi(id) {
  return request({
    url: '/mgr/app/client?appId=' + id,
    method: 'get'
  })
}

// 完善应用开发信息
export function beautifyInfo(obj) {
  return request({
    url: '/mgr/app/client/update?accessTokenValidity=' + obj.accessTokenValidity + '&appId=' + obj.appId + '&grantTypes=' +
    obj.grantTypes + '&redirectUrls=' + obj.redirectUrls + '&refreshTokenValidity=' + obj.refreshTokenValidity,
    method: 'post',
    data: obj
  })
}

// 应用列表
export function clientList(query) {
  return request({
    url: '/mgr/app/page',
    method: 'get',
    params: query
  })
}

// 删除应用信息
export function removeApi(obj) {
  return request({
    url: '/mgr/app/remove?id=' + obj.id,
    method: 'post',
    data: obj
  })
}

// 重置应用密钥
export function resetApi(obj) {
  return request({
    url: '/mgr/app/reset',
    method: 'post',
    data: obj
  })
}

// 编辑应用信息
export function updateApi(obj) {
  return request({
    url: '/mgr/app/update',
    method: 'post',
    data: obj
  })
}

// 应用下线
export function offlineApi(obj) {
  return request({
    url: '/mgr/app/offline?id=' + obj.id,
    method: 'post',
    data: obj
  })
}
// 应用下线
export function onlineApi(obj) {
  return request({
    url: '/mgr/app/online?id=' + obj.id,
    method: 'post',
    data: obj
  })
}

// 设置应用权限
export function setClientAnthuApi(obj) {
  return request({
    url: '/mgr/app/setAppPermission',
    method: 'post',
    data: obj
  })
}
// 查询应用权限
export function queryClientAnthuApi(query) {
  return request({
    url: '/mgr/app/queryAppPermission',
    method: 'get',
    params: query
  })
}
// 查询应用权限
export function queryAllClientAnthuApi(query) {
  return request({
    url: '/mgr/app/getApiListNotExistsChecked',
    method: 'get',
    params: query
  })
}

// 添加 、接入方白名单配置
export function addWhitelist(query) {
  return request({
    url: '/mgr/app/addWhitelist',
    method: 'post',
    data: query
  })
}

// 查询所有类型为公司的组织机构
export function listAllCompany() {
  return request({
    url: '/mgr/dept/listAllCompany',
    method: 'get'

  })
}
